<template>
  <div>
    <city-header/>
    <city-search :cities="cities"/>
    <city-list :hotList="hotCities" :cities="cities" :letter="letter"/>
    <city-alphabet :cities="cities" @changeLetter="handleClickLetter"/>
  </div>
</template>

<script>
import CityHeader from './components/Header'
import CitySearch from './components/Search'
import CityList from './components/List'
import CityAlphabet from './components/Alphabet'
import axios from 'axios'
export default {
  name: 'City',
  components: {
    CityHeader,
    CitySearch,
    CityList,
    CityAlphabet
  },
  data () {
    return {
      hotCities: [],
      cities: {},
      letter: ''
    }
  },
  created () {
    this.getCityInfo()
  },
  methods: {
    getCityInfo () {
      axios.get('/api/city.json').then(({ data }) => {
        this.hotCities = data.data.hotCities
        this.cities = data.data.cities
      })
    },
    handleClickLetter (letter) {
      this.letter = letter
    }
  }
}
</script>

<style>
</style>
